package com.bright.cwduijie.duijie.repository;

import com.bright.cwduijie.duijie.pojo.po.AccCode;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface AccCodeRepository extends JpaRepository<AccCode, Integer>, JpaSpecificationExecutor<AccCode> {

    @Query("select ZT_DATA_KEY from AccCode where sjjhbz = :sjjhbz group by ZT_DATA_KEY")
    List<String> getDistinctZtDataKeyBySjjhbz(@Param("sjjhbz") int sjjhbz);

    @Query("from AccCode where ZT_DATA_KEY=:ztDataKey and sjjhbz=:sjjhbz and opType=:opType and NF=:years")
    List<AccCode> getAccCodesByZTDATAKEYAndYearsAndSjjhbz(@Param("ztDataKey") String ztDataKey, @Param("sjjhbz") int sjjhbz,
                                                          @Param("opType") Integer opType, @Param("years") Integer years);

    @Query("from AccCode where ZT_DATA_KEY=:ztDataKey and opType=:opType and NF=:years")
    List<AccCode> getAccCodesByZTDATAKEYAndYears(@Param("ztDataKey") String ztDataKey,
                                                 @Param("opType") Integer opType, @Param("years") Integer years);

}